/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.hotel.test.model.impl;

import com.hotel.test.model.TblComment;
import com.hotel.test.model.TblCommentModel;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the TblComment service. Represents a row in the &quot;HT_TblComment&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.hotel.test.model.TblCommentModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link TblCommentImpl}.
 * </p>
 *
 * @author Vien-IT
 * @see TblCommentImpl
 * @see com.hotel.test.model.TblComment
 * @see com.hotel.test.model.TblCommentModel
 * @generated
 */
public class TblCommentModelImpl extends BaseModelImpl<TblComment>
	implements TblCommentModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a tbl comment model instance should use the {@link com.hotel.test.model.TblComment} interface instead.
	 */
	public static final String TABLE_NAME = "HT_TblComment";
	public static final Object[][] TABLE_COLUMNS = {
			{ "commentId", Types.BIGINT },
			{ "userId", Types.BIGINT },
			{ "userName", Types.VARCHAR },
			{ "createDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "comment_", Types.VARCHAR },
			{ "hotelId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table HT_TblComment (commentId LONG not null primary key,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,comment_ VARCHAR(75) null,hotelId LONG)";
	public static final String TABLE_SQL_DROP = "drop table HT_TblComment";
	public static final String ORDER_BY_JPQL = " ORDER BY tblComment.modifiedDate ASC";
	public static final String ORDER_BY_SQL = " ORDER BY HT_TblComment.modifiedDate ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.hotel.test.model.TblComment"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.hotel.test.model.TblComment"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.hotel.test.model.TblComment"));

	public TblCommentModelImpl() {
	}

	public long getPrimaryKey() {
		return _commentId;
	}

	public void setPrimaryKey(long primaryKey) {
		setCommentId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_commentId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return TblComment.class;
	}

	public String getModelClassName() {
		return TblComment.class.getName();
	}

	public long getCommentId() {
		return _commentId;
	}

	public void setCommentId(long commentId) {
		_commentId = commentId;
	}

	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public String getUserName() {
		if (_userName == null) {
			return StringPool.BLANK;
		}
		else {
			return _userName;
		}
	}

	public void setUserName(String userName) {
		_userName = userName;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public String getComment() {
		if (_comment == null) {
			return StringPool.BLANK;
		}
		else {
			return _comment;
		}
	}

	public void setComment(String comment) {
		_comment = comment;
	}

	public long getHotelId() {
		return _hotelId;
	}

	public void setHotelId(long hotelId) {
		_hotelId = hotelId;
	}

	@Override
	public TblComment toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (TblComment)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					TblComment.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		TblCommentImpl tblCommentImpl = new TblCommentImpl();

		tblCommentImpl.setCommentId(getCommentId());
		tblCommentImpl.setUserId(getUserId());
		tblCommentImpl.setUserName(getUserName());
		tblCommentImpl.setCreateDate(getCreateDate());
		tblCommentImpl.setModifiedDate(getModifiedDate());
		tblCommentImpl.setComment(getComment());
		tblCommentImpl.setHotelId(getHotelId());

		tblCommentImpl.resetOriginalValues();

		return tblCommentImpl;
	}

	public int compareTo(TblComment tblComment) {
		int value = 0;

		value = DateUtil.compareTo(getModifiedDate(),
				tblComment.getModifiedDate());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		TblComment tblComment = null;

		try {
			tblComment = (TblComment)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = tblComment.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<TblComment> toCacheModel() {
		TblCommentCacheModel tblCommentCacheModel = new TblCommentCacheModel();

		tblCommentCacheModel.commentId = getCommentId();

		tblCommentCacheModel.userId = getUserId();

		tblCommentCacheModel.userName = getUserName();

		String userName = tblCommentCacheModel.userName;

		if ((userName != null) && (userName.length() == 0)) {
			tblCommentCacheModel.userName = null;
		}

		Date createDate = getCreateDate();

		if (createDate != null) {
			tblCommentCacheModel.createDate = createDate.getTime();
		}
		else {
			tblCommentCacheModel.createDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			tblCommentCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			tblCommentCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		tblCommentCacheModel.comment = getComment();

		String comment = tblCommentCacheModel.comment;

		if ((comment != null) && (comment.length() == 0)) {
			tblCommentCacheModel.comment = null;
		}

		tblCommentCacheModel.hotelId = getHotelId();

		return tblCommentCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(15);

		sb.append("{commentId=");
		sb.append(getCommentId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", userName=");
		sb.append(getUserName());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", comment=");
		sb.append(getComment());
		sb.append(", hotelId=");
		sb.append(getHotelId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(25);

		sb.append("<model><model-name>");
		sb.append("com.hotel.test.model.TblComment");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>commentId</column-name><column-value><![CDATA[");
		sb.append(getCommentId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userName</column-name><column-value><![CDATA[");
		sb.append(getUserName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>comment</column-name><column-value><![CDATA[");
		sb.append(getComment());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>hotelId</column-name><column-value><![CDATA[");
		sb.append(getHotelId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = TblComment.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			TblComment.class
		};
	private long _commentId;
	private long _userId;
	private String _userUuid;
	private String _userName;
	private Date _createDate;
	private Date _modifiedDate;
	private String _comment;
	private long _hotelId;
	private transient ExpandoBridge _expandoBridge;
	private TblComment _escapedModelProxy;
}